﻿#pragma once
#pragma execution_character_set("UTF-8")

#include <osgViewer/Viewer>
#include <osgViewer/ViewerEventHandlers>
#include <osgViewer/api/win32/GraphicsWindowWin32>
#include <osgGA/TrackballManipulator>
#include <osgGA/MultiTouchTrackballManipulator>
#include <osgGA/KeySwitchMatrixManipulator>
#include <osgDB/DatabasePager>
#include <osgDB/Registry>
#include <osgDB/ReadFile>
#include <osgDB/WriteFile>
#include <osgUtil/Optimizer>
#include <osgQt/GraphicsWindowQt>

#include <osgViewer/CompositeViewer>
#include <osg/MatrixTransform>
#include <osg/PositionAttitudeTransform>
#include <osg/Depth>
#include <osg/Point>
#include <osg/LineWidth>
#include <osg/LineSegment>
#include <osg/Projection>
#include <osg/Image>
#include <osg/ShapeDrawable>
#include <osg/Light>
#include <osg/LightSource>
#include <osg/StateSet>
#include <osg/BoundingSphere>
#include <osg/Geode>
#include <osg/Node>
#include <osg/Group>
#include <osgText/Text>
#include <osg/Camera>
//#include <osg/CameraNode>
#include <osg/Geometry>
#include <osg/Switch>
#include <osgShadow/ShadowedScene>
//#include <osgShadow/ShadowVolume>
#include <osgShadow/ShadowTexture>
#include <osgShadow/ShadowMap>
#include <osgShadow/ParallelSplitShadowMap>
#include <osgShadow/SoftShadowMap>
#include <osg/ShapeDrawable>
#include <osg/ComputeBoundsVisitor>
#include <osg/BoundingBox>
#include <osg/BoundingSphere>
#include <osg/AnimationPath>
#include <osg/StateSet>
#include <osg/TexGen>
#include <osg/BlendColor>
#include <osg/BlendFunc>

#include <osg/LightModel>

#include <math.h>
#include <stdio.h>
#include <string>
#include <iostream>
#include <process.h>
#include <assert.h>
#include <stdarg.h>
#include <vector>

/*颜色*/
#define OSG_COLOR_RED     osg::Vec4f(0.8f, 0.0f, 0.0f, 1.0f)//
#define OSG_COLOR_GREEN   osg::Vec4f(0.0f, 1.0f, 0.0f, 1.0f)//
#define OSG_COLOR_BLUE    osg::Vec4f(0.0f, 0.0f, 1.0f, 1.0f)//
#define OSG_COLOR_YELLOW  osg::Vec4f(1.0f, 1.0f, 0.0f, 1.0f)//
#define OSG_COLOR_CYAN	  osg::Vec4f(0.0f, 1.0f, 1.0f, 1.0f)//
#define OSG_COLOR_GRAY    osg::Vec4f(0.2f, 0.2f, 0.2f, 1.0f)//
#define OSG_COLOR_BLACK   osg::Vec4f(0.0f, 0.0f, 0.0f, 1.0f)//
#define OSG_COLOR_ORANGE  osg::Vec4f(1.0f, 0.5f, 0.5f, 1.0f)//
#define OSG_COLOR_PURPLE  osg::Vec4f(0.8f, 0.0f, 0.8f, 1.0f)//
#define OSG_COLOR_WHITE   osg::Vec4f(1.0f, 1.0f, 1.0f, 1.0f)//
#define OSG_COLOR_TITLE   osg::Vec4f(3.0f, 0.5f, 0.0f, 1.0f)//
#define OSG_COLOR_DEFAULT osg::Vec4f(0.2f, 0.2f, 0.4f, 1.0f)//

/*字体*/
#define OSG_FONT_SONGTI		 "C:\\WINDOWS\\Fonts\\STSONG.ttf"   //宋简
#define OSG_FONT_HWSONGTI	 "C:\\WINDOWS\\Fonts\\STFANGSO.TTF" //华文仿宋
#define OSG_FONT_KATITI		 "C:\\WINDOWS\\Fonts\\simkai.ttf"	//楷体
#define OSG_FONT_HEITI		 "C:\\WINDOWS\\Fonts\\simhei.ttf"	//黑体
#define OSG_FONT_FANGSONG	 "C:\\WINDOWS\\Fonts\\simfang.ttf"	//仿宋
#define OSG_FONT_LISHU		 "C:\\WINDOWS\\Fonts\\SIMLI.TTF"	//隶书
#define OSG_FONT_XINSONG	 "C:\\WINDOWS\\Fonts\\SIMSUN.TTC"	//新宋体
#define OSG_FONT_XINGKAI	 "C:\\WINDOWS\\Fonts\\STXINGKA.TTF" //行楷
#define OSG_FONT_WEI_YAHEI	 "C:\\WINDOWS\\Fonts\\msyh.TTF"		//微软雅黑

/*英制和公制转换*/
#define OSG_TRANS_RATE   0.03937

/*树节点TreeNode类型编号*/
#define NODE_GROUP    0x0001//组节点
#define NODE_MOVE     0x0002//运动节点
#define NODE_INSTALL  0x0003//安装节点
#define NODE_MODEL    0x0004//模型节点
#define NODE_SWITCH   0x0005//开关节点
#define NODE_TEXT     0x0006//文本节点
#define NODE_HUD      0x0007//HUD节点
#define NODE_LIGHT    0x0008//光源节点


/*相机Camera类型编号*/
#define CAMERA_USUAL  0x0101//普通相机

/*节点属性编号*/
#define ATRRIBUTE_01     0x00000001
#define ATRRIBUTE_02     0x00000002
#define ATRRIBUTE_03     0x00000004
#define ATRRIBUTE_04     0x00000008
#define ATRRIBUTE_05     0x00000010
#define ATRRIBUTE_06     0x00000020
#define ATRRIBUTE_07     0x00000040
#define ATRRIBUTE_08     0x00000080
#define ATRRIBUTE_09     0x00000100
#define ATRRIBUTE_10     0x00000200
#define ATRRIBUTE_11     0x00000400
#define ATRRIBUTE_12     0x00000800
#define ATRRIBUTE_13     0x00001000
#define ATRRIBUTE_14     0x00002000
#define ATRRIBUTE_15     0x00004000
#define ATRRIBUTE_16     0x00008000
#define ATRRIBUTE_17     0x00010000
#define ATRRIBUTE_18     0x00020000
#define ATRRIBUTE_19     0x00040000
#define ATRRIBUTE_20     0x00080000

#define SWITCH_ON   0xFF  //开关节点-显示
#define SWITCH_OFF  0xFE  //开关接点-隐藏



template <class Type> class TypeArray
{
public:
    Type *pType;
    va_list ap;
    int va_num;
public:
    TypeArray()
    {
        va_num = 0;
        pType = NULL;
    }
    TypeArray( int LengthOfArray,...)
    {
        va_num  = LengthOfArray;
        pType = new Type[LengthOfArray];

        va_start(ap, LengthOfArray);

        for (int i = 0; i < va_num; i++)  // access each item in argument list
        {
            pType[i] = va_arg(ap, Type);
        }

        va_end(ap);
    }
    TypeArray( int LengthOfArray,Type *pInput)
    {
        va_num  = LengthOfArray;
        pType = new Type[LengthOfArray];
        memcpy_s(pType,sizeof(Type)*LengthOfArray,pInput,sizeof(Type)*LengthOfArray);
    }
    ~TypeArray()
    {
        delete pType;
    }
};

typedef TypeArray<double>   DoubleArray;
typedef TypeArray<float>    FloatArray;
typedef TypeArray<int>      IntArray;
typedef TypeArray<char>     CharArray;
typedef TypeArray<char*>    CharPtrArray;
